import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: HP
 * Date: 2023 -03 -10
 * Time: 13:25
 */
public class test {
    public static void func(int n) {
        int left = 0, right = n - 1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (left == right && left == j) {
                    System.out.print("*");
                    left++;
                    right--;
                } else if (j == left) {
                    System.out.print("*");
                    left++;
                } else if (j == right) {
                    System.out.print("*");
                    right--;
                } else {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }
    }

    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int x = in.nextInt();
            func(x);
        }
    }

    public static void func() {
        double sum = 0;
        for (int i = 1; i <= 100; i++) {
            if (i % 2 == 1) {
                sum += 1.0 / i;
            } else {
                sum -= 1.0 / i;
            }
        }
        System.out.println("sum=" + sum);
    }


    public static int fac(int n) {
        if (n < 2) return n;
        int fac = 1;
        for (int i = 2; i <= n; i++) {
            fac *= i;
        }
        return fac;
    }

    public static int fac2(int n) {
        if (n < 2) return n;
        int fac = 1;
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            fac *= i;
            sum += fac;
        }
        return sum;
    }

    public static int fib(int n) {
        if (n == 0 || n == 1) return n;
        int f1 = 0;
        int f2 = 1;
        int f3 = 0;
        for (int i = 2; i <= n; i++) {
            f3 = f1 + f2;
            f1 = f2;
            f2 = f3;
        }
        return f3;
    }

    public static int sum(int a, int b) {
        return a + b;
    }

    public static double sum(double a, double b) {
        return a + b;
    }

    public static int retMax(int a, int b) {
        return a > b ? a : b;
    }

    public static double retMax(double a, double b) {
        return a > b ? a : b;
    }

    public static double retMax(double a, double b, double c) {
        double ret1 = retMax(a, b);
        double ret2 = retMax(a, c);
        return ret1 > ret2 ? ret1 : ret2;
    }



    public static void main11(String[] args) {
        int[] arr = new int[100];
        for (int i = 0; i < 100; i++) {
            arr[i] = i;
        }
        System.out.println(Arrays.toString(arr));
    }

    public static void printArray(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
    }

    public static void main21(String[] args) {
        int[] arr = new int[100];
        for (int i = 0; i < 100; i++) {
            arr[i] = i;
        }
        printArray(arr);
    }

    public static int transform(int[] arr) {
        if (arr == null || arr.length == 0) return 0;
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        return sum;
    }
    public static double avg(int[] arr) {
        if (arr == null || arr.length == 0) return 0;
        double sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        return sum /= arr.length;
    }

    public static void main3(String[] args) {
        int[] arr = new int[100];
        for (int i = 0; i < 100; i++) {
            arr[i] = i;
        }
        printArray(arr);
        transform(arr);
        printArray(arr);
    }

    public static void func1(int[] arr) {
        int left = 0, right = arr.length - 1;
        while (left < right) {
            while (left < right && arr[left] % 2 == 1) left++;
            while (left < right && arr[right] % 2 == 0) right--;
            if (left < right) {
                int tmp = arr[left];
                arr[left] = arr[right];
                arr[right] = tmp;
            } else
                break;
        }
    }

    public static int binSearch(int[] arr, int n) {
        if (arr == null || arr.length == 0) return -1;
        int left = 0, right = arr.length - 1;
        while (left <= right) {
            int mid = (left + right) / 2;
            if (arr[mid] == n) return mid;
            else if (arr[mid] < n) left = mid + 1;
            else right = mid - 1;
        }
        return -1;
    }
    public static void bublSort(int[]arr){
        for(int i=0;i<arr.length-1;i++){
            for(int j=0;j<arr.length-1-i;j++){
                if(arr[j]>arr[j+1]){
                    int tmp=arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=tmp;
                }
            }
        }
    }
    public static void main(String[] args) {
        int[] arr = {1, 78,34,4, 12, 323,16, 23, 34,22, 45, 65};
        printArray(arr);
        bublSort(arr);
        printArray(arr);

    }
}
